/*
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 */
function onDeleteInComingOrder(url, Id, resp) {
	var isOK = -1;
	
	if(!confirm('Are you sure you want to delete the Order with Id:' + Id)) {
		return false;
	}
	
	new Ajax.Request(url, {
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=delincomingorder&id=' + Id,
	  onSuccess: function(transport) {
			var response = transport.responseText || "";
			var pos=response.indexOf('<!');
			content=response.substring(0,pos);
			
			obj = content.evalJSON();

    		if(obj == null) {
    			$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
    		
    		isOK = obj.ID;
		
    		$(resp).update(obj.message);
		}
	});

	$(resp).style.display = 'inherit';
	Fat.fade_element(resp, null, 1500, null, null);

	if(isOK == 0) {
		rowID = 'row_'+Id;
		Fat.fade_element(rowID, null, 1000, "#f22", null);
		setTimeout("$(rowID).remove()", 1000);
		
	}				
}

function onSendPDF(url, Id, resp) {
	new Ajax.Request(url, {
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=sendPDF&id=' + Id,
	  onSuccess: function(transport) {
			var response = transport.responseText || "";
			var pos=response.indexOf('<!');
			content=response.substring(0,pos);
			
			obj = content.evalJSON();

    		if(obj == null) {
    			$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
    		
    		isOK = obj.ID;
		
    		$(resp).update(obj.message);
		}
	});

	$(resp).style.display = 'inherit';
	Fat.fade_element(resp, null, 1500, null, null);
}

function onChangePaid(url, Id,checkid,resp) {
	var txt='';	
	if(checkid.checked != true)
		txt = 'in';
	if(!confirm('Are you sure you want to change status of the Order with Id:' + Id)) {
		if(checkid.checked == true)
			checkid.checked =false;
		else
			checkid.checked =true;
		return false;
	}
	$value = 0;	
	if(checkid.checked == true)
		$value = 1;
	new Ajax.Request(url, {
	  method: 'post',
	  asynchronous: false,
	  parameters:'act=changepaid&id='+Id+'&value=' + $value,
	  onSuccess: function(transport) {		
	  	var response = transport.responseText || "";
			var pos=response.indexOf('<!');
			content=response.substring(0,pos);
			
			obj = content.evalJSON();

    		if(obj == null) {
    			$(resp).innerHTML = 'Something wrong! Reponsed string is: ' + response;
    		}
    		
    		isOK = obj.code;
		
    		$(resp).update(obj.message);
	 }
	});
	$(resp).style.display = 'inherit';
	Fat.fade_element(resp, null, 1500, null, null);
		
}